public class Application {
    public static void say(People people){
        people.sayArea();
    }
    public static void main(String[] args) {
        ChinesePeople chinesePeople = new ChinesePeople("小强",20);
//        chinesePeople.intro();
//        chinesePeople.sayArea();
        say(chinesePeople);
        JapanesePeople japanesePeople = new JapanesePeople("桃太郎",22);
        say(japanesePeople);


        // 向上转型
//        People people = new ChinesePeople("小刚",22);
//        people.intro();
//        people.sayArea();

//        System.out.println(people instanceof ChinesePeople);
//        System.out.println(people instanceof People);
//        System.out.println(people instanceof JapanesePeople);
//        if(people instanceof ChinesePeople){
//            ChinesePeople cp = (ChinesePeople) people;
//            cp.sayArea();
//        }
//
//        ChinesePeople cp1 = (ChinesePeople) new People("小王",30);
//        cp1.sayArea();

//        SuperArray arr = new SuperArray();
//        arr.add("aaa");
//        arr.add(new ChinesePeople("小刚",22));
//
//        arr.remove(0);
//
//
//        for(int i = 0;i < arr.size();i++){
//            System.out.println(arr.get(i));
//        }

        Object [] objs = new Object[]{
                new ChinesePeople("张三",20),
                new ChinesePeople("李四",20),
                new ChinesePeople("王五",20),
                new ChinesePeople("张三",20),
        };
        Object [] newObjs = ArrayUtil.distinct(objs, new IDistinct() {
            @Override
            public boolean distinct(Object obj1, Object obj2) {
                ChinesePeople cp1 = (ChinesePeople) obj1;
                ChinesePeople cp2 = (ChinesePeople) obj2;
                return cp1.getAge() == cp2.getAge();
            }
        });
        for(int i = 0;i < newObjs.length;i++){

            System.out.println(newObjs[i]);
        }
    }
}
